package javawork03;

import java.util.ArrayList;

public class homework04 {
	public static void main(String[] args) {
		ArrayList<Integer> list = new ArrayList<Integer>();
		int count = 0;
		for (int i = 2; i < 1000; i++) {
			byte flag = 0;
			for (int j = 2; j < i; j++) {
				if (i % j == 0)
					flag = 1;
			}
			if (flag == 0)
				list.add(i);
		}
		for (int i = 0; i < list.size(); i++) {
			int ge = list.get(i) % 10;
			int bai = list.get(i) / 100;
			int shi = list.get(i) / 10 % 10;
			if (ge == bai || (bai == 0 && ge == shi) || (bai == 0 && shi == 0)) {
				count++;
				if (count < 10)
					System.out.print(list.get(i) + " ");
				else {
					System.out.println(list.get(i));
					count = 0;
				}
			}
		}
	}
}
